package cn.tedu.mybatisannotation.mapper;

import cn.tedu.mybatisannotation.pojo.UserVO;
import cn.tedu.mybatisannotation.pojo.Weibo;
import cn.tedu.mybatisannotation.pojo.WeiboVO;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface WeiboMapper {
    @Insert("INSERT INTO weibo VALUES (NULL,#{content},#{created},#{userId})")
    int insert(Weibo weibo);

    @Delete("DELETE FROM weibo WHERE id=#{id}")
    int deleteById(int id);

    @Update("UPDATE weibo SET content=#{content},created=#{created},user_id=#{userId} WHERE id=#{id}")
    int updateById(Weibo weibo);

    @Select("SELECT * FROM weibo")
    List<Weibo>selectAll();

    @Select("SELECT * FROM weibo WHERE id=#{id}")
    Weibo selectById(int id);

    @Select("SELECT content,created FROM weibo")
    List<WeiboVO> selectByCol();

}
